﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Exceptions
{
    class Students
    {
        int age;
        string gender;
        string name;
        int classNumber;

        public int Age
        {
            get
            {
                return age;
            }
            set
            {
                if (age < 7 || age > 18)
                {
                    throw new InvalidStudentException(string.Format("invalid age: {0}", age));
                }
                age = value;
            }
        }

        public string Gender
        {
            get
            {
                return gender;
            }
            set
            {
                if (gender.ToLower() != "male" || gender.ToLower() != "female")
                {
                    throw new InvalidStudentException(string.Format("invalid gender: {0}", gender));
                }
                gender = value;
            }
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (name.Length < 10 || name.Length > 50)
                {
                    throw new InvalidStudentException(string.Format("name must be between 10 and 50 characters: {0}", name));
                }
                name = value;
            }
        }

        public int ClassNumber
        {
            get
            {
                return classNumber;
            }
            set
            {
                if (ClassNumber < 1 || ClassNumber > 11)
                {
                    throw new InvalidStudentException(string.Format("invalid class number, number must be between 1 and 11. You entered: {0}", classNumber));
                }
                classNumber = value;
            }
        }

        public Students(int age, string gender, string name, int classNumber)
        {
            if (age < 7 || age > 18) 
            {
                throw new InvalidStudentException(string.Format("invalid age: {0}",age));
            }
            this.age = age;
            if (gender.ToLower() != "male" || gender.ToLower() != "female")
            {
                throw new InvalidStudentException(string.Format("invalid gender: {0}", gender));
            }
            this.gender = gender;
            if (name.Length<10||name.Length>50)
            {
                throw new InvalidStudentException(string.Format("name must be between 10 and 50 characters: {0}", name));
            }
            this.name = name;
            if (ClassNumber < 1 || ClassNumber > 11)
            {
                throw new InvalidStudentException(string.Format("invalid class number, number must be between 1 and 11. You entered: {0}", classNumber));
            }
            this.classNumber = classNumber;
        }
    }
}
